package manager;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import gameobj.ElementType;
import gameobj.GameObject;

/**
 * @名称 游戏元素管理器
 * @author YOU友/Passerby
 *
 */
public class ElementManager {
public static ElementManager instance = null;
	
	private Map<ElementType, List<GameObject>> elementsMap = null;
	
	private ElementManager() {
		init();
	}
	
	public void init() {
		elementsMap = new HashMap<ElementType, List<GameObject>>();
		elementsMap.put(ElementType.PLAYER, new ArrayList<GameObject>());
		elementsMap.put(ElementType.ENVIRONMENT, new ArrayList<GameObject>());
		elementsMap.put(ElementType.ENEMY, new ArrayList<GameObject>());
		elementsMap.put(ElementType.SPAWNPOINT, new ArrayList<GameObject>());
		elementsMap.put(ElementType.BOSS, new ArrayList<GameObject>());
		elementsMap.put(ElementType.ITEM, new ArrayList<GameObject>());
	}
	
	public static ElementManager get() {
		if (instance == null) {
			instance = new ElementManager();
		}
		
		return instance;
	}
	
	public List<GameObject> getList(ElementType type) {
		return elementsMap.get(type);
	}
	
	public void add(ElementType key, GameObject value) {
		elementsMap.get(key).add(value);
	}
	
	public void reset() {
		elementsMap.put(ElementType.ENVIRONMENT, new ArrayList<GameObject>());
		elementsMap.put(ElementType.ENEMY, new ArrayList<GameObject>());
		elementsMap.put(ElementType.SPAWNPOINT, new ArrayList<GameObject>());
		elementsMap.put(ElementType.BOSS, new ArrayList<GameObject>());
		elementsMap.put(ElementType.ITEM, new ArrayList<GameObject>());
	}
}
